package _021_11_16

type ListNode struct {
	Val  int
	Next *ListNode
}

func Merge(pHead1 *ListNode, pHead2 *ListNode) *ListNode {
	head := &ListNode{}
	tail_node := head
	canContinueList := pHead1
	for pHead1 != nil && pHead2 != nil {
		if pHead1.Val < pHead2.Val {
			tail_node.Next = pHead1
			pHead1 = pHead1.Next
		} else {
			tail_node.Next = pHead2
			pHead2 = pHead2.Next
		}
		tail_node = tail_node.Next
	}
	if pHead1 == nil {
		canContinueList = pHead2
	}
	tail_node.Next = canContinueList
	return head.Next
}
